package com.sixth.controller.wx;

import com.sixth.bean.common.BasePageInfo;
import com.sixth.bean.common.BaseRespVo;
import com.sixth.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author qys
 * @Description
 * @date 2022/9/11 13:55
 */
@RestController
@RequestMapping("wx/topic")
public class WXTopicController {
    @Autowired
    TopicService topicService;
    // qys
    static Integer wxTopicRelatePage = 1;
    static Integer wxTopicRelateLimit = 4;


    @RequestMapping("list")
    public BaseRespVo wxTopicList(BasePageInfo basePageInfo) {
        Object wxTopicListVOList = topicService.wxTopicList(basePageInfo);
        return BaseRespVo.ok(wxTopicListVOList);
    }

    @RequestMapping("detail")
    public BaseRespVo wxTopicDetail(Integer id) {
        WXTopicDetailVO wxTopicDetailVO = topicService.wxTopicDetail(id);
        return BaseRespVo.ok(wxTopicDetailVO);
    }

    @RequestMapping("related")
    public BaseRespVo wxTopicRelate(Integer id) {
        BasePageInfo basePageInfo = new BasePageInfo();
        basePageInfo.setPage(wxTopicRelatePage);
        basePageInfo.setLimit(wxTopicRelateLimit);
        // TODO : 相关专题分页和数量优化
        Object wxTopicRelateVO = topicService.wxTopicRelate(id, basePageInfo);
        return BaseRespVo.ok(wxTopicRelateVO);
    }
}
